package com.ng.mapper;

import com.ng.common.annotation.AutoFill;
import com.ng.common.enumeration.OperationEnum;
import com.ng.model.dto.UserPageDTO;
import com.ng.model.po.User;
import com.github.pagehelper.Page;
import org.apache.ibatis.annotations.*;

import java.util.Map;

/**
 * 用户接口 Mapper
 *
 * @author Ng
 * @date 2024/03/07
 */
@Mapper
public interface UserMapper {

    @Select("select * from tb_user where user_name=#{userName};")
    User login(String userName);

    @AutoFill(OperationEnum.INSERT)
    @Insert("insert into tb_user(user_name, pass_word, name, phone, sex, create_time, change_time, create_by, change_by) " +
            "value (#{userName}, #{passWord}, #{name}, #{phone}, #{sex}, #{createTime}, #{changeTime}, #{createBy}, #{changeBy});")
    void insert(User user);

    @AutoFill(OperationEnum.UPDATE)
    void update(User user);

    @Update("update tb_user set delete_flag = '1' where user_id=#{userId};")
    void deleteById(Long userId);

    @Delete("delete from tb_user where user_id=#{userId};")
    void deleteById2(Long userId);

    @Select("select * from tb_user where user_id = #{userId};")
    User getById(Long userId);

    Page<User> pageQuery(UserPageDTO userPageDTO);

    Integer countByUserId(Map map);
}
